package com.stone.mpandroidchartdemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

    private ListView mListView;
    private ArrayAdapter<String> mAdapter;
    private String[] datas;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        initView();
    }

    private void initView() {
        mListView = findViewById(R.id.listView);
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(this);
    }

    private void initData() {

        datas = getResources().getStringArray(R.array.onclick_title);
        mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,datas);
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

        Intent intent;
        switch (i) {
            case 0: {

                intent = new Intent(this, BarChartActivity.class);
                startActivity(intent);
                break;
            }

            default:
                break;

        }
    }
}
